<template>
  <template v-for="menu in menus" :key="menu.path">
    <el-sub-menu v-if="menu.children" :index="menu.path">
      <template #title>
        <el-icon>
          <component :is="menu.meta.icon"></component>
        </el-icon>
        <span>{{ menu.meta.title }}</span>
      </template>
      <menu-item :menus="menu.children"></menu-item>
    </el-sub-menu>

    <el-menu-item v-else @click="toPath(menu.name)" :index="menu.name">
      <el-icon>
        <component :is="menu.meta.icon"></component>
      </el-icon>
      <span>{{ menu.meta.title }}</span>
    </el-menu-item>
  </template>
</template>

<script lang="ts" setup>
import router from "../../../router";

defineProps(['menus'])

const toPath = (item: string) => {
  router.push({name: item});
}
</script>

<style scoped lang="scss">

</style>
